package com.wthink.hzgj.sdcard

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.findNavController
import com.wthink.hzgj.R
import com.wthink.hzgj.databinding.FragmentSdcardBinding
import com.wthink.hzgj.sdcard.viewmodel.SdcardViewmodel


class SdcardFragment  : Fragment() {

    private val viewModel by viewModels<SdcardViewmodel>()

    private lateinit var binding : FragmentSdcardBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(
            inflater,
            R.layout.fragment_sdcard,
            container,
            false
        )
        binding.viewModel = viewModel
        binding.lifecycleOwner = this
        return binding.root
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)

        binding.back.setOnClickListener {
            it.findNavController().popBackStack()
        }

        viewModel.start()
    }
}